<!DOCTYPE html>
<html><head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport"
		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<title>云螭行后台管理</title>

	<!-- Set render engine for 360 browser -->
	<meta name="renderer" content="webkit">

	<!-- No Baidu Siteapp-->
	<meta http-equiv="Cache-Control" content="no-siteapp"/>

	<link rel="icon" type="image/png" href="/images/logoP.png">

	<!-- Add to homescreen for Chrome on Android -->
	<meta name="mobile-web-app-capable" content="yes">
	<link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png">

	<!-- Add to homescreen for Safari on iOS -->
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-title" content="云螭行"/>
	<link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">

	<!-- Tile icon for Win8 (144x144 + tile color) -->
	<meta name="msapplication-TileImage" content="assets/i/app-icon72x72@2x.png">
	<meta name="msapplication-TileColor" content="#0e90d2">
  <link href="//cdn.bootcss.com/semantic-ui/2.2.6/semantic.min.css" rel="stylesheet">
  <script src="//cdn.bootcss.com/jquery/3.0.0/jquery.min.js"></script>
  <script src="//cdn.bootcss.com/semantic-ui/2.2.6/semantic.min.js"></script>
  <%= javascript_include_tag 'enquire.min' %>

  <style type="text/css">
    body {
      background-color: #DADADA;
    }
    body > .grid {
      height: 100%;
    }
    .image {
      margin-top: -100px;
    }
    .column {
      max-width: 450px;
    }
  </style>
	<script type="text/javascript">
	var c=91;//倒计时90秒
	var t;
	  function timecounter(){
	    if (c==0) {
	      document.getElementById('sms').value = '获取手机验证码';
	      $("#sms").removeClass('disabled');
	      return;

	    }
	    t=setTimeout("timecounter()",1000);

	    c--;
	    document.getElementById('sms').value=c+'秒之后重新获取';


	    return c;
	  }
	  function sendsms(event){
	    //
	    // 此处接入短信平台
	    var phonereg = /^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
	    var mobile_number = $("#valid_mobile").val();


	    if (!phonereg.test(mobile_number)) {
	      alert('请输入正确的手机号！');
	      return ;
	    }

	    $.get('/login/sms', {mobile: mobile_number}, function(result){
	      var obj = JSON.parse(result);
	      // console.log(result);
	      if (obj.sub_code == 'isv.MOBILE_NUMBER_ILLEGAL') {
	        $.get('/login/removeSms');
	        alert('请输入正确的手机号！');
	        return
	      }
	      if (obj.sub_code == 'isv.BUSINESS_LIMIT_CONTROL') {
	        $.get('/login/removeSms');
	        alert('您的操作过于频繁，请稍后再试试！');
	        return
	      }
	      if (obj.result.success) {
	        alert('您的验证码已经发送至您的手机'+mobile_number+",请注意查收");
	        $("#sms").addClass('disabled');
	        t = timecounter();
	        return
	      }
	    });



	  }


	  $(document).ready(function(){
	    $('.ui.form').form({
	    on: 'submit',
	    fields: {
	      mobile: {
	        identifier: 'mobile',
	        rules: [
	          {
	            type   : 'empty',
	            prompt : '手机号码没了吗？'
	          }
	        ]
	      },
	      smstext: {
	        identifier: 'smstext',
	        rules: [
	          {
	            type   : 'exactLength[4]',
	            prompt : '请输入至少4位验证码'
	          }
	        ]
	      },
	      gender: {
	        identifier: 'gender',
	        rules: [
	          {
	            type   : 'empty',
	            prompt : 'Please select a gender'
	          }
	        ]
	      },
	      username: {
	        identifier: 'username',
	        rules: [
	          {
	            type   : 'empty',
	            prompt : 'Please enter a username'
	          }
	        ]
	      },
	      password: {
	        identifier: 'password',
	        rules: [
	          {
	            type   : 'empty',
	            prompt : 'Please enter a password'
	          },
	          {
	            type   : 'minLength[6]',
	            prompt : 'Your password must be at least {ruleValue} characters'
	          }
	        ]
	      },
	      terms: {
	        identifier: 'terms',
	        rules: [
	          {
	            type   : 'checked',
	            prompt : '你怎么能不同意条款！'
	          }
	        ]
	      }
	    }
	  })
	;
	  });

	</script>

</head>
<body data-feedly-mini="yes">

<div class="ui middle aligned center aligned grid">
  <div class="column">
    <h2 class="ui teal image header">
      <img src="/log.jpg" class="small image">
      <div class="content">
        登录云螭行后台管理系统
      </div>
    </h2>
		<div class="twelve wide  center aligned padding column">
			<%= flash_tag(:error, :class => 'ui error message transition flash-notice') %>
			<%= flash_tag(:success, :class => 'ui success message transition flash-notice' )%>
			<script type="text/javascript">
				$('.flash-notice').fadeOut(3500);
			</script>
			<% form_tag url(:login, :by_username), :class=>"ui large form" do %>
			<div class="ui stacked ">

				<div class="field">
					<div class="ui left icon input">
						<i class="user icon"></i>
						<input type="text" id="valid_mobile" name="username" value="" placeholder='请输入您的用户名'><br/>
					</div>
				</div>

				<div class="field">
					<div class="ui left icon input">
						<i class="key icon"></i>
						<input type="password" name="password" value="" placeholder='请输入您的密码'>
					</div>
				</div>

				<div class="field">
					<input type="submit" value="登录" class="ui fluid large basic red submit button">
				</div>

			</div>

			<div class="ui error message">

			</div>


		<% end %>


  </div>
</div>

</body>
</html>
